package service

import (
	"api-gateway/basic/config"
	__ "api-gateway/basic/proto/rpc"
	"api-gateway/handler/request"
	"github.com/gin-gonic/gin"
	"net/http"
)

func PayMember(c *gin.Context) {
	var form request.PayMember
	if err := c.ShouldBind(&form); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"code": 400, "msg": "参数错误"})
		return
	}
	url, err := config.VideoRpcClient.PayMember(c, &__.PayMemberReq{
		UserId:   int64(form.UserId),
		MemberId: int64(form.MemberId),
	})
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"code": 400, "msg": "充值失败"})
		return
	}
	c.JSON(http.StatusOK, gin.H{"code": 200, "msg": "支付Url", "data": gin.H{
		"url": url,
	}})
	return
}
